// 导入组件
import Vue from 'vue';
import Router from 'vue-router';

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}

const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => err)
}

// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    mode: 'history',
    routes: [{
            path: '/',
            name: '',
            component: () =>
                import ('../views/login.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        }, {
            path: '/login',
            name: '登录',
            component: () =>
                import ('../views/login.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/register',
            name: '注册',
            component: () =>
                import ('../views/register.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/index',
            name: '首页',
            component: () =>
                import ('../views/index.vue'),
            iconCls: 'el-icon-tickets',
            children: [{
                    path: '/manager/student',
                    name: 'Student',
                    component: () =>
                        import ('../views/user/student.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/manager/teacher',
                    name: 'Teacher',
                    component: () =>
                        import ('../views/user/teacher.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/manager/manager',
                    name: 'Manager',
                    component: () =>
                        import ('../views/user/manager.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/class',
                    name: 'Class',
                    component: () =>
                        import ('../views/class'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/course',
                    name: 'Course',
                    component: () =>
                        import ('../views/course'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/grade',
                    name: 'Grade',
                    component: () =>
                        import ('../views/grade'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/grade/checkGrade',
                    name: 'CheckGrade',
                    component: () =>
                        import ('../views/grade/checkGrade.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/grade/real',
                    name: 'Real',
                    component: () =>
                        import ('../views/grade/real.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/grade/realHistory',
                    name: 'RealHistory',
                    component: () =>
                        import ('../views/grade/realHistory.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/term',
                    name: 'Term',
                    component: () =>
                        import ('../views/term'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/teaching',
                    name: 'Teaching',
                    component: () =>
                        import ('../views/teaching'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/own',
                    name: 'Own',
                    component: () =>
                        import ('../views/own'),
                    meta: {
                        requireAuth: true
                    }
                }
            ]
        }
    ]
})